
$(document).ready(function() {
    if(attendanceStatus == "正常"){
    	$('#signTime').attr("onclick", "");
    }
	var strs1= new Array(); //定义一数组 
	var strs2= new Array(); //定义一数组 
	strs1=signTime.split(":"); //字符分割 
	strs2=clockTime.split(":"); //字符分割 
	if(attendanceStatus == "迟到"){
		var total = (parseInt(strs2[0])-parseInt(strs1[0]))*3600;
		    total+= (parseInt(strs2[1])-parseInt(strs1[1]))*60;
		    total+= (parseInt(strs2[2])-parseInt(strs1[2]))
		var total = total/60.0;
		    var h = total+"";
		    if(h.indexOf(".")>-1){
		    	$("#status").text("迟到"+h.substring(0,h.indexOf("."))+"分钟");
		    }else{
		    	$("#status").text("迟到"+h+"分钟");
		    }
		    
	}
	if(attendanceStatus == "早退"){
		var total = (parseInt(strs1[0])-parseInt(strs2[0]))*3600;
		    total+= (parseInt(strs1[1])-parseInt(strs2[1]))*60;
		    total+= (parseInt(strs1[2])-parseInt(strs2[2]))
		var total = total/60.0;
		    var h = total+"";
		    if(h.indexOf(".")>-1){
		    	$("#status").text("早退"+h.substring(0,h.indexOf("."))+"分钟");
		    }else{
		    	$("#status").text("早退"+h+"分钟");
		    }
		    
	}
});


function attendanceAdd(){
	if(clockTime == $("#signTime").val()){
		jalert9("保存成功！");
		setTimeout(function(){
			parent.searchData();
			closeAttendance();
		},WARN_TIME_OUT);
	}else{
		$.ajax({ 
		 	url: ctp + "/attenRecordController/attenRecordSave.shtml",
		    data: $('#form1').serialize(),
			type : 'POST',
			async:false, 
			success : function(result) {  
				if(result=='1') {  
					jalert9("保存成功！");
					setTimeout(function(){
						parent.searchData();
						closeAttendance();
					},WARN_TIME_OUT);
				} else if(result=='0') {     
					jalert("保存失败，请联系管理员！");   
				} 
	  		}
		});
	}
}

//function back(){
//	window.parent.closeDialogWin();
//}

//当前弹窗索引
var attendance_index = parent.layui.layer.getFrameIndex(window.name);

//关闭当前弹窗
function closeAttendance(){
	parent.layui.layer.close(attendance_index);
}